#ifndef ____HAL___H_H_____
#define ____HAL___H_H_____


#include <stdio.h>
#include <stdint.h>




#define HAL_SW0_PORT   GPIOA
#define HAL_SW0_PIN    GPIO_PIN_0
#define HAL_SW0_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW1_PORT   GPIOA
#define HAL_SW1_PIN    GPIO_PIN_0
#define HAL_SW1_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)

#define HAL_SW2_PORT   GPIOA
#define HAL_SW2_PIN    GPIO_PIN_0
#define HAL_SW2_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW3_PORT   GPIOA
#define HAL_SW3_PIN    GPIO_PIN_0
#define HAL_SW3_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW4_PORT   GPIOA
#define HAL_SW4_PIN    GPIO_PIN_0
#define HAL_SW4_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW5_PORT   GPIOA
#define HAL_SW5_PIN    GPIO_PIN_0
#define HAL_SW5_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW6_PORT   GPIOA
#define HAL_SW6_PIN    GPIO_PIN_0
#define HAL_SW6_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW7_PORT   GPIOA
#define HAL_SW7_PIN    GPIO_PIN_0
#define HAL_SW7_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW8_PORT   GPIOA
#define HAL_SW8_PIN    GPIO_PIN_0
#define HAL_SW8_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW9_PORT   GPIOA
#define HAL_SW9_PIN    GPIO_PIN_0
#define HAL_SW9_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW10_PORT   GPIOA
#define HAL_SW10_PIN    GPIO_PIN_0
#define HAL_SW10_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW11_PORT   GPIOA
#define HAL_SW11_PIN    GPIO_PIN_0
#define HAL_SW11_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW12_PORT   GPIOA
#define HAL_SW12_PIN    GPIO_PIN_0
#define HAL_SW12_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)

#define HAL_SW13_PORT   GPIOA
#define HAL_SW13_PIN    GPIO_PIN_0
#define HAL_SW13_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW14_PORT   GPIOA
#define HAL_SW14_PIN    GPIO_PIN_0
#define HAL_SW14_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW15_PORT   GPIOA
#define HAL_SW15_PIN    GPIO_PIN_0
#define HAL_SW15_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW16_PORT   GPIOA
#define HAL_SW16_PIN    GPIO_PIN_0
#define HAL_SW16_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW17_PORT   GPIOA
#define HAL_SW17_PIN    GPIO_PIN_0
#define HAL_SW17_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)



#define HAL_SW18_PORT   GPIOA
#define HAL_SW18_PIN    GPIO_PIN_0
#define HAL_SW18_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW19_PORT   GPIOA
#define HAL_SW19_PIN    GPIO_PIN_0
#define HAL_SW19_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW20_PORT   GPIOA
#define HAL_SW20_PIN    GPIO_PIN_0
#define HAL_SW20_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)


#define HAL_SW21_PORT   GPIOA
#define HAL_SW21_PIN    GPIO_PIN_0
#define HAL_SW22_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)




#define HAL_SW22_PORT   GPIOA
#define HAL_SW22_PIN    GPIO_PIN_0
#define HAL_SW22_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)



#define HAL_SW23_PORT   GPIOA
#define HAL_SW23_PIN    GPIO_PIN_0
#define HAL_SW23_INPUT  gpio_input_bit_get(HAL_SW0_PORT,HAL_SW0_PIN)



#define HAL_LED0_PORT   GPIOA
#define HAL_LED0_PIN    GPIO_PIN_0
#define HAL_LED0_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED1_PORT   GPIOA
#define HAL_LED1_PIN    GPIO_PIN_0
#define HAL_LED1_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED1_PORT,HAL_LED1_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED1_PORT,HAL_LED1_PIN,SET);};}while(0);

#define HAL_LED2_PORT   GPIOA
#define HAL_LED2_PIN    GPIO_PIN_0
#define HAL_LED2_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);

#define HAL_LED3_PORT   GPIOA
#define HAL_LED3_PIN    GPIO_PIN_0
#define HAL_LED3_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED4_PORT   GPIOA
#define HAL_LED4_PIN    GPIO_PIN_0
#define HAL_LED4_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED5_PORT   GPIOA
#define HAL_LED5_PIN    GPIO_PIN_0
#define HAL_LED5_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED6_PORT   GPIOA
#define HAL_LED6_PIN    GPIO_PIN_0
#define HAL_LED6_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED7_PORT   GPIOA
#define HAL_LED7_PIN    GPIO_PIN_0
#define HAL_LED7_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED8_PORT   GPIOA
#define HAL_LED8_PIN    GPIO_PIN_0
#define HAL_LED8_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);

#define HAL_LED9_PORT   GPIOA
#define HAL_LED9_PIN    GPIO_PIN_0
#define HAL_LED9_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED10_PORT   GPIOA
#define HAL_LED10_PIN    GPIO_PIN_0
#define HAL_LED10_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED11_PORT   GPIOA
#define HAL_LED11_PIN    GPIO_PIN_0
#define HAL_LED11_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED12_PORT   GPIOA
#define HAL_LED12_PIN    GPIO_PIN_0
#define HAL_LED12_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED13_PORT   GPIOA
#define HAL_LED13_PIN    GPIO_PIN_0
#define HAL_LED13_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED14_PORT   GPIOA
#define HAL_LED14_PIN    GPIO_PIN_0
#define HAL_LED14_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);

#define HAL_LED15_PORT   GPIOA
#define HAL_LED15_PIN    GPIO_PIN_0
#define HAL_LED15_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED16_PORT   GPIOA
#define HAL_LED16_PIN    GPIO_PIN_0
#define HAL_LED16_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED17_PORT   GPIOA
#define HAL_LED17_PIN    GPIO_PIN_0
#define HAL_LED17_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);								



#define HAL_LED18_PORT   GPIOA
#define HAL_LED18_PIN    GPIO_PIN_0
#define HAL_LED18_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);



#define HAL_LED19_PORT   GPIOA
#define HAL_LED19_PIN    GPIO_PIN_0
#define HAL_LED19_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);

								

#define HAL_LED20_PORT   GPIOA
#define HAL_LED20_PIN    GPIO_PIN_0
#define HAL_LED20_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED21_PORT   GPIOA
#define HAL_LED21_PIN    GPIO_PIN_0
#define HAL_LED21_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);								

#define HAL_LED22_PORT   GPIOA
#define HAL_LED22_PIN    GPIO_PIN_0
#define HAL_LED22_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);


#define HAL_LED23_PORT   GPIOA
#define HAL_LED23_PIN    GPIO_PIN_0
#define HAL_LED23_OUTPUT(value) do{ if(value>0){ gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,RESET);}\
								else{gpio_bit_write(HAL_LED0_PORT,HAL_LED0_PIN,SET);};}while(0);								


#define HAL_UART_TX_PORT GPIOA
#define HAL_UART_TX_PIN  GPIO_PIN_0
#define HAL_UART_TX_AF   GPIO_AFSEL0_SEL0

#define HAL_UART_RX_PORT GPIOA
#define HAL_UART_RX_PIN  GPIO_PIN_0
#define HAL_UART_RX_AF   GPIO_AFSEL0_SEL0

#define HAL_485_STA_PORT GPIOA
#define HAL_485_STA_PIN  GPIO_PIN_0
#define HAL_485_STA_INPUT gpio_input_bit_get(HAL_485_STA_PORT,HAL_485_STA_PIN)

#define HAL_USART_PORT USART0
#define HAL_USART_BAUDRATE  9600



uint32_t Hal_SysTick_Get(void);


/* this function handles SysTick exception */
void SysTick_Handler(void);

void USART1_IRQHandler(void);

void USART0_IRQHandler(void);



void Hal_Init(void);

void Hal_Uart_Send(uint8_t* pBuffer,uint32_t pLen);

void Hal_Uart_SendByte(uint8_t pData);

void Hal_Iwdgt_feed(void);




#endif

